

<template>
  <a-row :gutter="24">
    <a-col :span="8">
      <BhForm ref="formRef" v-model:model-value="from" :options="options" :columns="formColumns"/>
    </a-col>
    <a-col :span="16">

    </a-col>
  </a-row>
</template>
<script setup lang="ts">
import {type Columns, type Options,BhForm} from '@/components/BhForm'
import {AnyObject} from "@/types/global";
import {computed} from "vue";

const props = withDefaults(
    defineProps<
        Partial<{
          modelValue: AnyObject;
        }>
    >(),
    {

    }
)
const emits = defineEmits(['update:modelValue']);
const from = computed({
  get() {
    return props.modelValue;
  },
  set(e) {
    emits('update:modelValue', e);
  },
});
const options: Options = {
  form: {size: 'large'},
  btns: {hide: true},
}

const formRef = ref<InstanceType<typeof BhForm>>()
const formColumns: Columns = reactive([
  {
    label: '是否展示',
    field: 'is_show',
    type: 'radio-group',
    options: [
      { label: '显示', value: 1 },
      { label: '不展示', value: 2 },
    ],
    props:{
      type:'button'
    },
    rules: [{ required: true, message: '请选择表单状态' }],
  },

  {
    label: '删除类型',
    field: 'delete_type',
    type: 'select',
    hide:(form)=>{
      return form.is_show === 2
    },
    options: [
      { label: '单个删除', value: 1 },
      { label: '批量删除', value: 2 },
    ],
    props: {
      placeholder: '请选择删除类型',
      allowClear: true,
      multiple:true
    },
    rules: [{ required: true, message: '请选择删除类型' }],
  },

])
const onValidate =  async() => {
  return await formRef.value?.formRef?.validate();
}
defineExpose({onValidate})
</script>
<style scoped lang="less">

</style>